﻿using SFML.Graphics;

namespace WolfCarol.SFU
{
    public class SpriteRenderer : Renderer
    {
        public Transformable Transform => _sprite;

        private Sprite _sprite;

        public Texture? Sprite
        {
            get => _sprite.Texture;
            set => _sprite.Texture = value;
        }

        public Color Color
        {
            get => _sprite.Color;
            set => _sprite.Color = value;
        }

        public SpriteRenderer(string spritePath)
        {
            _sprite = new Sprite(new Texture(spritePath));
        }

        public SpriteRenderer(Texture texture)
        {
            _sprite = new Sprite(texture);
        }

        public SpriteRenderer(Sprite sprite)
        {
            _sprite = sprite;
        }

        public override void Draw(RenderTarget target, RenderStates states)
        {
            if (_sprite.Texture != null)
            {
                target.Draw(_sprite, states);
            }
        }
    }
}
